package ak;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;

public class Boss extends UntypedActor{

	ActorRef sender ; 
	
	@Override
	public void onReceive(Object arg0) throws Exception {
		if(arg0.equals("123")){
			sender = getSender();
			System.out.println(arg0);
			ActorRef worker = this.getContext().actorOf(Props.create(Worker.class));
			worker.tell("worker do work", getSelf());
		}else if(arg0.equals("456")){
			System.out.println(arg0);
			sender.tell("over", getSelf());
		}else if(arg0.equals("789")){
			sender = getSender();
			System.out.println(arg0);
			ActorRef worker = this.getContext().actorOf(Props.create(Worker.class));
			worker.tell("worker do work 1", getSelf());
		}
	}

}
